/*

*/

#include "lib/noise.cl"

kernel void Main (write_only image2d_t outImage)
{
	int2	coord = GetGlobalCoord().xy;
	real3	point = GetGlobalCoordTransformed( (real3)(1.0), (real3)(0.0) );

	// from libNoise sample //
	point = Turbulence( point, 1.0 / 8.0, 4.0, 6, 2 );
	real	primary_granite = Billow( point, 8.0, 2.18359375, 0.625, NOISE_QUALITY_STD, 6, 0 );
	real	base_grains		= Voronoi( point, DEFAULT_VORONOI_DISPLACEMENT, 16.0, 1, true );
	real	scaled_grains	= base_grains * (real)(-0.5);
	real	final_granite	= clamp( primary_granite + scaled_grains, -1.0, 1.0 );

	write_image( outImage, coord, final_granite );
}
